package com.zhiwei.controller;

import com.zhiwei.pojo.Repository;
import com.zhiwei.service.RepositoryService;
import com.zhiwei.vo.PageResult;
import com.zhiwei.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/repository")
public class RepositoryController {
    @Autowired
    private RepositoryService repositoryService;
    @GetMapping("/list")
    public SysResult getResptList(){
        List<Repository> list = repositoryService.getResptList();
        return SysResult.success(list);
    }
    @PostMapping("/newRepos")
    public SysResult newRepos(@RequestBody Repository repository){
        int i = repositoryService.newRepos(repository);
        return SysResult.success(i);
    }
    @PutMapping("/updateRepos")
    public SysResult updateRepos(@RequestBody Repository repository){
        int i = repositoryService.updateRepos(repository);
        return SysResult.success(i);
    }
    @DeleteMapping("/delete/{id}")
    public SysResult deleteRepos(@PathVariable Integer id){
        return SysResult.success(repositoryService.deleteRepos(id));
    }
}
